/************************************************************************/
/*    Author: Scott Bevin                                               */
/************************************************************************/

#pragma once

#include <string>

#include "PropertyFactory.h"

namespace XF
{
	class IProperty;

	class PropertyMakerBase
	{
	protected:
		PropertyMakerBase(){}

	public:
		virtual IProperty* MakeProperty(const std::string &name) = 0;

		virtual ~PropertyMakerBase(){}
	};

	template<class MakerType, class PropertyType>
	class PropertyMaker : public PropertyMakerBase
	{
	private:
		std::string mIDName;
		PropertyType mInitialValue;

	public:
		PropertyMaker(std::string id, PropertyType initialValue)
		{
			mIDName = id;
			mInitialValue = initialValue;

			PropertyFactory::RegisterMaker(id, typeid(PropertyType).name(), this);
		}

		IProperty* MakeProperty(const std::string &name)
		{
			MakerType *newProp = new MakerType(mIDName, name);
			newProp->Set(mInitialValue);
			return newProp;
		}
	};
}

